#include<stdio.h>
int main()
{
    int n;
    int count = 0;
    int bkxcd = 0;
    int x,y;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d",&x,&y);
        bkxcd = x+y+bkxcd-8;
        count += bkxcd;
    }
    printf("%d",count);
    return 0;
}
